<script>
    function debounce(fn, delay) {
        return function (args) {
            var that = this;
            console.log(this)
            clearTimeout(fn.id);
            // 定时器返回ID
            // fn 自由变量
            // fn 对象
            fn.id = setTimeout(function() {
                // this丢失问题
                fn.call(that, args);
            }, delay)
        }
    }
    let obj = {
        count: 0,
        inc: debounce(function (val) {
            // this
            console.log(this.count += val)
            console.log(this.count)
        }, 500)
    }
    obj.inc(1);
</script>